package model;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-12-06
 * Time: 22:37
 */
public class HashIdToArticle {
    public static MicroBlogConnect[] microBlogConnects = new MicroBlogConnect[10000007];

    public void insert(int id, MicroBlog blog){
        MicroBlogConnect node = microBlogConnects[id];
        if(node == null){
            MicroBlogConnect microBlogConnect = new MicroBlogConnect(blog);
            microBlogConnects[id] = microBlogConnect;
        }else{
            while(node.next != null){
                node = node.next;
            }
            MicroBlogConnect microBlogConnect = new MicroBlogConnect(blog);
            node.next = microBlogConnect;
        }
        System.out.println("添加文章成功");
        MicroBlogConnect cur = microBlogConnects[id];
        while(cur != null){
            System.out.println(cur.blog.getTitle());
            cur = cur.next;
        }
    }

    public MicroBlogConnect selectAll(int id){
        return microBlogConnects[id];
    }

    public MicroBlog selectOne(int blogId){
        return HashBlogIdToBlog.microBlogs[blogId];
    }
}
